package com.sibu.yx.promotion.common.enums;

import com.doubo.common.enums.BaseEnum;
import com.doubo.common.util.EnumUtil;

import lombok.Getter;

/**
 * Created with IntelliJ IDEA.
 * User: qiujingwang
 * Description: 登录类型（渠道）
 */
public enum LoginPlatEnum implements BaseEnum<Integer> {
    FROM_XWS(0, "XWS"),//新微商
    FROM_APP(1, "APP-IOS"),//APP 苹果
    FROM_WECHAT_NUMBER(2, "Wechat-Number"),//微信公众号
    FROM_THRID_LOGIN(3, "Thrid-Login"),//第三方登陆
    FROM_WEB(4, "WEB"),//网页
    FROM_XCX(5, "XCX"),//小程序
    ;

    @Getter
    private Integer code;
    @Getter
    private String desc;

    LoginPlatEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getDesc(int code) {
        for (LoginPlatEnum enumObj : LoginPlatEnum.values()) {
            if (enumObj.getCode() == code) {
                return enumObj.desc;
            }
        }
        return code + "";
    }

    public static LoginPlatEnum resolve(int value) {
        return EnumUtil.fromEnumValue(LoginPlatEnum.class, "code", value);
    }
}
